function jsonp(url, data = {}, callback = 'callback') {
  // 处理json对象，拼接url
  data.callback = callback;
  let params = [];
  for (let key in data) {
    params.push(key + '=' + data[key]);
  }
  let script = document.createElement('script');
  script.src = url + '?' + params.join('&');
  console.log(script);
  document.body.appendChild(script);

  return new Promise((resolve, reject) => {
    window[callback] = data => {
      try {
        resolve(data);
      } catch (err) {
        reject(err)
      } finally {
        script.parentNode.removeChild(script);
      }
    }
  })
}

// 请求数据
jsonp('http://photo.sina.cn/aj/index', {
  page: 1,
  cate: 'recommend',
}, 'jsoncallback').then(data => {
  console.log(data)
})